package com.tianyi.exception;

/**
 * @Author tianyi
 * @Description // todo
 * @Date 2022 - 11 - 05
 **/
public enum RestMsgEnum {
    SUCCESS(0,"SUCCESS"),
    FAIL(-1,"FAIL"),
    SERVER_BUSY(503,"Server is Busy now , please try it agagin");



    private int code;
    private String message;

    RestMsgEnum(int code, String message){
        this.code = code;
        this.message = message;
    }

    public int getCode(){
        return this.code;
    }
    public String getMessage(){
        return this.message;
    }

    public static String getMessageByCode(int code){
        for (RestMsgEnum msg: RestMsgEnum.values()) {
            if(msg.getCode() == code){
                return msg.message;
            }
        }
        return null;
    }
}
